package cn.edu.sdjzu.xg.eagle.service.impl;


import cn.edu.sdjzu.xg.eagle.entities.Material;

import cn.edu.sdjzu.xg.eagle.mapper.MaterialMapper;
import cn.edu.sdjzu.xg.eagle.service.inface.MaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;
@Service
public class MaterialImpl implements MaterialService {
    @Autowired
    private MaterialMapper materialMapper;
    @Override
    public String addMaterial(Material material) throws SQLException {
        if (materialMapper.addMaterial(material)) {
            return "添加Material成功";
        }
        return "添加Material失败";
    }
    @Override
    public String deleteMaterial(int id) throws SQLException {
        if (materialMapper.deleteMaterial(id)) {
            return "删除Material成功";
        } else {
            return "删除Material失败";
        }
    }

    @Override
    public String updateMaterial(Material material) throws SQLException {
        if (materialMapper.updateMaterial(material)) {
            return "更新Material成功";
        } else {
            return "更新Material失败";
        }
    }

    @Override
    public Material findMaterialById(int id) throws SQLException {
        return materialMapper.findMaterialById(id);
    }

    @Override
    public List<Material> findMaterials() throws SQLException {
        return materialMapper.findMaterials();
    }


}
